package com.tencent.liteav.demo.play.danke;

/**
 * 视频播放器管理器
 */
public class DKVideoPlayerManager {

    private IDKVideoPlayer mPlayer;

    private DKVideoPlayerManager() {
    }

    private static class SingletonHolder {
        private static final DKVideoPlayerManager INSTANCE = new DKVideoPlayerManager();
    }

    public static DKVideoPlayerManager getInstance() {
        return SingletonHolder.INSTANCE;
    }

    public IDKVideoPlayer getCurrentPlayer() {
        return mPlayer;
    }

    public void setCurrentPlayer(IDKVideoPlayer videoPlayer) {
        if (mPlayer != videoPlayer) {
            mPlayer = videoPlayer;
        }
    }

    public void onPause() {
        if (mPlayer != null) {
            mPlayer.onPause();
        }
    }

    public void onResume() {
        if (mPlayer != null) {
            mPlayer.onResume();
        }
    }

    public void onDestroy() {
        if (mPlayer != null) {
            mPlayer.release();
        }
    }

    public boolean onBackPressed() {
        // 如果是全屏
        if (mPlayer != null) {
            return mPlayer.onBackPressed();
        }
        return false;
    }
}
